package com.oldbook.manage.controller;

import com.oldbook.common.annotation.Log;
import com.oldbook.common.core.controller.BaseController;
import com.oldbook.common.core.domain.AjaxResult;
import com.oldbook.common.core.page.TableDataInfo;
import com.oldbook.common.enums.BusinessType;
import com.oldbook.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.oldbook.manage.domain.StudentInfo;
import com.oldbook.manage.service.IStudentInfoService;

/**
 * 学生信息维护Controller
 *
 * @author Exiaoke
 * @date 2025-02-18
 */
@RestController
@RequestMapping("/manage/studentInfo")
@Api(tags = "学生信息维护管理")
public class StudentInfoController extends BaseController {

    @Autowired
    private IStudentInfoService studentInfoService;

/**
 * 查询学生信息维护列表
 */
@PreAuthorize("@ss.hasPermi('manage:studentInfo:list')")
@GetMapping("/list")
@ApiOperation("查询学生信息维护列表")
    public TableDataInfo list(@ApiParam("学生信息维护对象") StudentInfo studentInfo) {
        startPage();
        List<StudentInfo> list = studentInfoService.selectStudentInfoList(studentInfo);
        return getDataTable(list);
    }

    /**
     * 导出学生信息维护列表
     */
    @PreAuthorize("@ss.hasPermi('manage:studentInfo:export')")
    @Log(title = "学生信息维护", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出学生信息维护列表")
    public void export(HttpServletResponse response, @ApiParam("学生信息维护对象") StudentInfo studentInfo) {
        List<StudentInfo> list = studentInfoService.selectStudentInfoList(studentInfo);
        ExcelUtil<StudentInfo> util = new ExcelUtil<StudentInfo>(StudentInfo.class);
        util.exportExcel(response, list, "学生信息维护数据");
    }

    /**
     * 获取学生信息维护详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:studentInfo:query')")
    @GetMapping(value = "/{studentId}")
    @ApiOperation("获取学生信息维护详细信息")
    public AjaxResult getInfo(@PathVariable("studentId") @ApiParam("studentId的值") Long studentId) {
        return success(studentInfoService.selectStudentInfoByStudentId(studentId));
    }

    /**
     * 新增学生信息维护
     */
    @PreAuthorize("@ss.hasPermi('manage:studentInfo:add')")
    @Log(title = "学生信息维护", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增学生信息维护")
    public AjaxResult add(@RequestBody @ApiParam("要添加的学生信息维护对象") StudentInfo studentInfo) {
        return toAjax(studentInfoService.insertStudentInfo(studentInfo));
    }

    /**
     * 修改学生信息维护
     */
    @PreAuthorize("@ss.hasPermi('manage:studentInfo:edit')")
    @Log(title = "学生信息维护", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改学生信息维护")
    public AjaxResult edit(@RequestBody @ApiParam("要修改的学生信息维护对象") StudentInfo studentInfo) {
        return toAjax(studentInfoService.updateStudentInfo(studentInfo));
    }

    /**
     * 删除学生信息维护
     */
    @PreAuthorize("@ss.hasPermi('manage:studentInfo:remove')")
    @Log(title = "学生信息维护", businessType = BusinessType.DELETE)
    @DeleteMapping("/{studentIds}")
    @ApiOperation("删除学生信息维护")
    public AjaxResult remove(@PathVariable @ApiParam("要删除的studentId数组") Long[] studentIds) {
        return toAjax(studentInfoService.deleteStudentInfoByStudentIds(studentIds));
    }
}